<template>
  <div id="app">
    <router-view />
    <van-tabbar v-model="active" active-color="#FF9900" inactive-color="#888787" v-if="showTab">
      <van-tabbar-item v-if="roleType == 'parent'" name="home" icon="home-o" to="Home">主页</van-tabbar-item>
      <van-tabbar-item v-if="roleType == 'teacher'" name="work" icon="notes-o" to="WorkBench">工作台</van-tabbar-item>
      <van-tabbar-item name="personal" icon="friends-o" to="Personal">个人中心</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import request from "@/utils/request.js";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      active: ""
    };
  },
  created() {
    if (this.roleType == "parent") {
      this.active = "home";
    }
    if (this.roleType == "teacher") {
      this.active = "work";
    }
  },
  methods: {},
  async mounted() {},
  computed: {
    showTab() {
      switch (this.$route.name) {
        case "Home":
          this.active = "home";
          return true;
          break;
        case "WorkBench":
          this.active = "work";
          return true;
          break;
        case "Personal":
          this.active = "personal";
          return true;
          break;
      }
      return false;
    },
    ...mapGetters({ roleType: "getRoleType" })
  }
};
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f7f7f7;
  color: #2c3e50;
}
body {
  background-color: #f7f7f7;
}
.row-space-around {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
}
.column-space-around {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}
.column-space-between {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.column-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.row-center {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.flex-row {
  display: flex;
  flex-direction: row;
}
.flex-column {
  display: flex;
  flex-direction: column;
}
.line-m {
  text-decoration: line-through;
}
.row-align-center {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.column-align-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.row-space-between {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.row-flex-end {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
}
</style>
